using System;
using AppToolKit.Core.Context.Spring;

namespace CenterDateAchieve
{
    public class AutoWiringFactory
    {
        public static T Create<T>() where T:IAutoWiring
        {
            T obj = Activator.CreateInstance<T>();
            Instance.Context.AutowireObject(obj);
            return obj;

 
        }

        private static  AutoWiringFactory  instance_;
        private ContextAware contextAware_;

        public static  void SetContext(ContextAware context)        
        {
            Instance.Context = context; 
        }

        private  static AutoWiringFactory Instance
        {
            get
            {
                if(instance_==null)
                    instance_=new AutoWiringFactory();
                return instance_;
            }
        }

        public ContextAware Context
        {
            get { return contextAware_; }
            set { contextAware_ = value; }
        }
    }
}